package com.totoro.dao;

import java.util.HashMap;
import java.util.Map;

import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.totoro.domain.Tutorial;

/*
 * 指导老师与毕业设计关联类（设计指导关系）dao
 */
@Repository
public class TutorialDao extends BaseHibernateDao<Tutorial, Integer>{
	
	public TutorialDao(){
	}
	
	// 查询唯一指导关系
	public Tutorial uniqueTutorial(Object tutor,Object project){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("tutor", tutor);
		map.put("project", project);
		Criterion crigerion = Restrictions.allEq(map);
		Criteria criteria = this.createCriteria().add(crigerion);
		return (Tutorial) criteria.uniqueResult();
	}
}
